﻿//========================================================= 
/**@file VisaPayCmdDriver.h
 * @brief 
 * 
 * @date 2017-09-14   00:47:46
 * @author Zhyioo 
 * @version 1.0
 */ 
//--------------------------------------------------------- 
#ifndef _LIBZHOUYB_VISAPAYCMDDRIVER_H_
#define _LIBZHOUYB_VISAPAYCMDDRIVER_H_
//--------------------------------------------------------- 
#include "../CommonCmdDriver.h"

#include "../../pboc/VisaPay.h"
using zhou_yb::application::pboc::VisaPayAppAdapter;
//--------------------------------------------------------- 
namespace zhou_yb {
namespace application {
namespace driver {
//--------------------------------------------------------- 
/**
 * @brief VisaPay支付驱动
 * @date 2017-09-14 00:38:11
 */
class VisaPayCmdDriver :
    public CommonCmdDriver, 
    public BaseDevAdapterBehavior<ITransceiveTrans>
{
protected:
    VisaPayAppAdapter _icAdapter;
public:
    VisaPayCmdDriver() : CommonCmdDriver()
    {
        _errGetter.Add(_icAdapter);
        _logSetter.select(_icAdapter);

        _RegisteCMD(VisaPayCmdDriver, GetCardNumber);
        _RegisteAdapterCMD(VisaPayCmdDriver);
    }
    LC_CMD_ADAPTER_INVOKE(ITransceiveTrans, _icAdapter);
    /**
     * @brief 获取VisaPay卡号
     * @date 2017-09-14 00:40
     *
     * @param [in] TLV : hex 交易相关的TLV数据
     * 
     * @retval  CardNumber : string 获取到的卡号
     * @retval  TLV : hex 获取到的应用数据
     */
    LC_CMD_METHOD(GetCardNumber)
    {
        string sTlv = arg["TLV"].To<string>();

        ByteBuilder terminalTlv(32);
        ByteBuilder cardNumber(8);
        ByteBuilder appData(32);

        DevCommand::FromAscii(sTlv.c_str(), terminalTlv);
        
        rlt.Put("CardNumber", cardNumber.GetString());
        rlt.Put("TLV", ArgConvert::ToString(terminalTlv));
        return true;
    }
};
//--------------------------------------------------------- 
} // nemespace driver
} // namespace application
} // namespace zhou_yb
//--------------------------------------------------------- 
#endif // _LIBZHOUYB_VISAPAYCMDDRIVER_H_
//========================================================= 